#include <common_def.h>
#include <cmath>
#include <Rectangle.h>


Rectangle::Rectangle(double width, double height)
{
	width_m = FLOOR2(width);
	height_m = FLOOR2(height);
}

bool Rectangle::isValid() const
{
	return IN_RANGE(width_m, 0, 100) &&
		IN_RANGE(height_m, 0, 75);
}

double Rectangle::getArea() const
{
	double area = ROUND2(width_m*height_m);
	return isValid() ? area : INVALID_VALUE_FOR_RECT;
}

double Rectangle::getPerimeter() const
{
	double perimeter = ROUND2(2*(width_m+height_m));
	return isValid() ? perimeter : INVALID_VALUE_FOR_RECT;
}

bool Rectangle::setWidth(double width)
{
	width_m = FLOOR2(width);
	return IN_RANGE(width_m, 0, 100);
}

bool Rectangle::setHeight(double height)
{
	height_m = FLOOR2(height);
	return IN_RANGE(height_m, 0, 75);
}